package com.project.weather.common;

import java.io.Serializable;

public class ResultMap<C, R> implements Serializable {
    private static final long serialVersionUID = -3440414747436194409L;
    private C code;
    private R result;

    public ResultMap() {
        this.code = (C) AResultCode.FAIL;
    }

    public ResultMap(C code) {
        this.code = code;
    }

    public ResultMap(C code, R result) {
        this.code = code;
        this.result = result;
    }

    public C getCode() {
        return this.code;
    }

    public ResultMap setCode(C code) {
        this.code = code;
        return this;
    }

    public R getResult() {
        return this.result;
    }

    public ResultMap setResult(R result) {
        this.result = result;
        return this;
    }

    public boolean equals(Object obj) {
        if (obj != null && this.getClass().isInstance(obj)) {
            ResultMap<C, R> t = (ResultMap)obj;
            return t.code == this.code && t.result == this.result;
        } else {
            return false;
        }
    }

    public String toString() {
        return "ResultMap [code=" + this.code + ", result=" + this.result + "]";
    }
}
